;;; c-code.el --- config c code

;; 頭文件自動補全
(require 'company-c-headers)

(setq xtoolchain-path "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain")
(setq sdk-path "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk")
(add-to-list 'company-c-headers-path-system
	     (concat xtoolchain-path "/usr/include/c++/v1"))
(add-to-list 'company-c-headers-path-system
	     (concat xtoolchain-path "/usr/lib/clang/7.0.0/include"))
(add-to-list 'company-c-headers-path-system
	     (concat xtoolchain-path "/usr/include"))
(add-to-list 'company-c-headers-path-system
	     (concat sdk-path "/usr/include"))
(add-to-list 'company-c-headers-path-system
	     (concat sdk-path "/System/Library/Frameworks"))


(defun my/c-mode-hook ()
  (add-to-list 'company-backends 'company-c-headers))
(add-hook 'c-mode-hook 'my/c-mode-hook)
(add-hook 'c++-mode-hook 'my/c-mode-hook)

;; 設置 C-c C-o 爲打開頭文件的快捷鍵
(add-hook 'c-initialization-hook
          (lambda ()
            (define-key c-mode-base-map
              [(control x) (control o)] 'ff-find-other-file)))
